from interface.MemberInterface import MemberInterface
from utils.SendMethod import SendMethod


class AddressInterface:
    def __init__(self, url):
        self.url = url
        self.headers = MemberInterface(url).get_token("KFC7516", "654321")

    def add_address(self, payload):
        url = self.url + '/member/address/add'
        return SendMethod.send_method(method='post', url=url, json=payload, headers=self.headers)

    def get_address_list(self):
        url = self.url + '/member/address/list'
        return SendMethod.send_method(method='get', url=url, headers=self.headers)


if __name__ == '__main__':
    url = "http://47.108.206.100:8085"
    address = AddressInterface(url)
    payload = {
        "city": "武汉市",
        "defaultStatus": 0,
        "detailAddress": "一个很无奈的地方",
        "id": 0,
        "memberId": 0,
        "name": "KF",
        "phoneNumber": "18009187516",
        "postCode": "654321",
        "province": "湖北省",
        "region": "汤逊湖旁边"
    }
    # print(address.add_address(payload=payload))
    print(address.get_address_list())